﻿$(function () {
    $('#btn').click(function () {
        var loginId = $('#txtLoginId').val();
        var pwd = $('#txtPassword').val();

        if (loginId.replace(/(^\s*)|(\s*$)/g, "").length === 0) {
            layer.tips('请输入用户名！', '#txtLoginId');
            return;
        }
        if (pwd.replace(/(^\s*)|(\s*$)/g, "").length === 0) {
            layer.tips('请输入密码！', '#txtPassword');
            return;
        }
        $("#loading").show();
        $.ajax({
            url: '/Account/Login',
            dataType: "json",
            type: 'post',
            data: {
                loginId: loginId,
                pwd: pwd
            },
            success: function (data) {
                if (data.success) {
                    location.href = '/';
                } else {
                    layer.msg(data.msg);
                }
            }
        });
    });
});